package com.ruoyi.report_lq.controller;

import java.util.List;
import java.util.Arrays;

import com.ruoyi.report_lq.domain.bo.LqrhdjlbBaDetailBo;
import com.ruoyi.report_lq.domain.vo.LqrhdjlbBaDetailVo;
import com.ruoyi.report_lq.service.ILqrhdjlbBaDetailService;
import lombok.RequiredArgsConstructor;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.*;

import cn.dev33.satoken.annotation.SaCheckLogin;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 沥青软化点记录
 *
 * @author zyb
 * @date 2024-06-11
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/syrw/lqLqrhdjlbBaDetail")
public class LqrhdjlbBaDetailController extends BaseController {

    private final ILqrhdjlbBaDetailService iReportLqLqrhdjlbBaDetailService;

    /**
     * 查询沥青软化点记录列表
     */
    @SaCheckLogin
    @GetMapping("/list")
    public TableDataInfo<LqrhdjlbBaDetailVo> list(LqrhdjlbBaDetailBo bo, PageQuery pageQuery) {
        return iReportLqLqrhdjlbBaDetailService.queryPageList(bo, pageQuery);
    }

    /**
     * 导出沥青软化点记录列表
     */
    @SaCheckLogin
    @Log(title = "沥青软化点记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(LqrhdjlbBaDetailBo bo, HttpServletResponse response) {
        List<LqrhdjlbBaDetailVo> list = iReportLqLqrhdjlbBaDetailService.queryList(bo);
        ExcelUtil.exportExcel(list, "沥青软化点记录", LqrhdjlbBaDetailVo.class, response);
    }

    /**
     * 获取沥青软化点记录详细信息
     *
     * @param lqrhdid 主键
     */
    @SaCheckLogin
    @GetMapping("/{lqrhdid}")
    public R<LqrhdjlbBaDetailVo> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long lqrhdid) {
        return R.ok(iReportLqLqrhdjlbBaDetailService.queryById(lqrhdid));
    }

    /**
     * 新增沥青软化点记录
     */
    @SaCheckLogin
    @Log(title = "沥青软化点记录", businessType = BusinessType.INSERT)
    @RepeatSubmit()
    @PostMapping()
    public R<Void> add(@Validated(AddGroup.class) @RequestBody LqrhdjlbBaDetailBo bo) {
        return toAjax(iReportLqLqrhdjlbBaDetailService.insertByBo(bo));
    }

    /**
     * 修改沥青软化点记录
     */
    @SaCheckLogin
    @Log(title = "沥青软化点记录", businessType = BusinessType.UPDATE)
    @RepeatSubmit()
    @PutMapping()
    public R<Void> edit(@Validated(EditGroup.class) @RequestBody LqrhdjlbBaDetailBo bo) {
        return toAjax(iReportLqLqrhdjlbBaDetailService.updateByBo(bo));
    }

    /**
     * 删除沥青软化点记录
     *
     * @param lqrhdids 主键串
     */
    @SaCheckLogin
    @Log(title = "沥青软化点记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{lqrhdids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] lqrhdids) {
        return toAjax(iReportLqLqrhdjlbBaDetailService.deleteWithValidByIds(Arrays.asList(lqrhdids), true));
    }
}
